package cn.zktr.Personnel.controllers.zhouxiong;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.zktr.Personnel.common.DateListString;
import cn.zktr.Personnel.common.TimeStamp;
import cn.zktr.Personnel.model.pojos.*;
import cn.zktr.Personnel.model.service.zhouxiong.*;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;

@Controller
public class KaoQinShuJuController {
	
	@Autowired
	private KaoQinKaService kqk;

	@RequestMapping("zx/kao-qin-shu-ju")
	public void zhujiemian() {}
	
	/**考勤数据
	 * @param date
	 * @param page
	 * @param rows
	 * @return
	 */
	@RequestMapping("KaoQinShuJu")
	@ResponseBody
	public Map<String,Object> kaoqin(String date,int page,int rows) {
		Map<String,Object> map = new HashMap<>();
		map.put("total",kqk.seleKaoQinShuJu(date).size());
		Page<Object> p=PageHelper.startPage(page,rows);
		JSONArray dates = kqk.seleKaoQinShuJu(date);
		map.put("rows",dates);
		return map;
	}
	
	/**考勤数据
	 * @param date
	 * @param page
	 * @param rows
	 * @return
	 */
	@RequestMapping("YuanGongKaoQins")
	@ResponseBody
	public List<JSONObject> kaoqins(Integer empid,String date) {
		List<JSONObject> dates = kqk.seleYuanGongKaoQin(empid,date);
		return dates;
	}
	
	
	/**考勤结果
	 * @param date
	 * @param page
	 * @param rows
	 * @return
	 */
	@RequestMapping("KaoQinShuJuJieGuo")
	@ResponseBody
	public Map<String,Object> kaoqinJieGuo(String date,int page,int rows) {
		Map<String,Object> map = new HashMap<>();
		kqk.seleKaoQinShuJuYuanGong(date);
		map.put("total",kqk.seleKaoQinShuJuYuanGong(date).size());
		Page<Object> p=PageHelper.startPage(page,rows);
		List<JSONObject> dates = kqk.seleKaoQinShuJuYuanGong(date);
		map.put("rows",dates);
		return map;
	}
	
	@PostMapping("updateKaoQinShuJu")
	@ResponseBody
	public String updateKaoQinShuJu(Integer resid,Integer empid,String rsnreason,String resrem) {
		String jieguo = kqk.updateKaoQinShuJu( resid, empid, rsnreason, resrem);
		return jieguo;
	}
}
